package cn.tedu.hotel.controller;

import cn.tedu.hotel.pojo.dto.RoomTypeAddNewDTO;
import cn.tedu.hotel.service.IRoomTypeService;
import cn.tedu.hotel.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *   处理房价与房间类型关联数据相关的控制器
 */
@Api(tags = "06. 房间与房间类型关联管理模块")
@Slf4j
@RestController
@RequestMapping("/room-type")
public class RoomTypeController {

    @Autowired
    IRoomTypeService roomTypeService;

    public RoomTypeController(){
        log.debug("创建控制器：RoomTypeController");
    }

    @ApiOperation("添加房间与房间类型关联")
    @ApiOperationSupport(order = 100)
    @PostMapping("/add-new")
    public JsonResult<Void> addNew(RoomTypeAddNewDTO roomTypeAddNewDTO){
        log.debug("开始处理【添加房间与房间类型关联】的请求，参数：{}",roomTypeAddNewDTO);
        roomTypeService.addNew(roomTypeAddNewDTO);
        return JsonResult.ok();
    }


    @ApiOperation("根据房间id删除房间与房间类型关联数据")
    @ApiOperationSupport(order = 200)
    @PostMapping("/{roomId:[0-9]+}/delete")
    public JsonResult<Void> deleteByRoomId(@PathVariable Long roomId){
        log.debug("开始处理【删除房间id为{}也房间类型关联数据】的请求",roomId);
        roomTypeService.deleteByRoomId(roomId);
        return JsonResult.ok();
    }

}
